package day13.XuLHL;

import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectOutputStream;

public class ObjectOutputStreamDemo {
    public static void main(String[] args) throws IOException {
        //ObjectOutputStream(OutputStream out)：创建一个写入指定的OutputStream的ObjectOutputStream
        ObjectOutputStream os = new ObjectOutputStream(new FileOutputStream("D://itheima//nb.txt"));

        //创建对象
        Student s = new Student("王某某", 25);

        //void writeObject(Object obj)：将指定的对象写入ObjectOutputStream
        os.writeObject(s);

        //释放资源
        os.close();
    }
}
